package work.mediway.bi.model.dto;

import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * @author lipengfei_ylrj <lipengfei_ylrj@mediway.cn><br/>
 * @date 2023/3/22
 */

public class BaseDTO {

    public static final Integer DEFAULT_PAGE = 1;

    public static final Integer DEFAULT_PAGE_SIZE = 1000;
    @ApiModelProperty("页数")
    @Setter
    private int current;
    @ApiModelProperty("每页条数")
    @Setter
    private int size;

    /**
     * 排序字段
     */
    @ApiModelProperty(value = "排序字段", hidden = true)
    @Setter
    @Getter
    @JsonIgnore
    private String field;


    /**
     * 排序规则，asc升序，desc降序
     */
    @ApiModelProperty(value = "排序规则", hidden = true)
    @Setter
    @Getter
    @JsonIgnore
    private String order;

    public int getCurrent() {
        if (ObjectUtil.isEmpty(current) || current < 1) {
            current = DEFAULT_PAGE;
        }
        return current;
    }

    public int getSize() {
        if (ObjectUtil.isEmpty(size) || size < 1) {
            size = DEFAULT_PAGE_SIZE;
        }
        return size;
    }
}
